package com.atguigu.gmall.order.pay.rpc;


import com.alipay.api.AlipayApiException;
import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.order.pay.config.PayTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/api/inner/payment")
public class PayRestController {


    @Autowired
    PayTemplate payTemplate;

    @PostMapping("/check/sign")
    public Result checkSign(@RequestBody Map<String,String> params){
        try {
            boolean sgin = payTemplate.checkSgin(params);
            if(sgin){
                return Result.ok();
            }
            return Result.fail();
        } catch (AlipayApiException e) {
            return Result.fail();
        }
    }
}
